﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
using DQYT.HTDZ.BLL;
using DQYT.HTDZ.Model;

namespace DQYT.HTDZ.Web.BDPOVERMACHINE
{
    public partial class Modify : Page
    {       

        protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					decimal DJID=(Convert.ToDecimal(Request.Params["id"]));
					ShowInfo(DJID);
				}
			}
		}
			
	private void ShowInfo(decimal DJID)
	{
		BDPOVERMACHINEBLL bll=new BDPOVERMACHINEBLL();
		BDPOVERMACHINEModel model=bll.GetModel(DJID);
		this.lblDJID.Text=model.DJID.ToString();
		this.txtDJXH.Text=model.DJXH;
		this.txtDJMC.Text=model.DJMC;
		this.txtDJLB.Text=model.DJLB;
		this.txtSCCJ.Text=model.SCCJ;
		this.txtDJGL.Text=model.DJGL.ToString();
		this.txtDJTDFS.Text=model.DJTDFS;
		this.txtDJZS.Text=model.DJZS.ToString();
		this.txtISVALID.Text=model.ISVALID.ToString();
		this.txtISUSED.Text=model.ISUSED.ToString();
		this.txtBZ.Text=model.BZ;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtDJXH.Text.Trim().Length==0)
			{
				strErr+="DJXH不能为空！\\n";	
			}
			if(this.txtDJMC.Text.Trim().Length==0)
			{
				strErr+="DJMC不能为空！\\n";	
			}
			if(this.txtDJLB.Text.Trim().Length==0)
			{
				strErr+="DJLB不能为空！\\n";	
			}
			if(this.txtSCCJ.Text.Trim().Length==0)
			{
				strErr+="SCCJ不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtDJGL.Text))
			{
				strErr+="DJGL格式错误！\\n";	
			}
			if(this.txtDJTDFS.Text.Trim().Length==0)
			{
				strErr+="DJTDFS不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtDJZS.Text))
			{
				strErr+="DJZS格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtISVALID.Text))
			{
				strErr+="ISVALID格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtISUSED.Text))
			{
				strErr+="ISUSED格式错误！\\n";	
			}
			if(this.txtBZ.Text.Trim().Length==0)
			{
				strErr+="BZ不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			decimal DJID=decimal.Parse(this.lblDJID.Text);
			string DJXH=this.txtDJXH.Text;
			string DJMC=this.txtDJMC.Text;
			string DJLB=this.txtDJLB.Text;
			string SCCJ=this.txtSCCJ.Text;
			decimal DJGL=decimal.Parse(this.txtDJGL.Text);
			string DJTDFS=this.txtDJTDFS.Text;
			decimal DJZS=decimal.Parse(this.txtDJZS.Text);
			decimal ISVALID=decimal.Parse(this.txtISVALID.Text);
			decimal ISUSED=decimal.Parse(this.txtISUSED.Text);
			string BZ=this.txtBZ.Text;


			BDPOVERMACHINEModel model=new BDPOVERMACHINEModel();
			model.DJID=DJID;
			model.DJXH=DJXH;
			model.DJMC=DJMC;
			model.DJLB=DJLB;
			model.SCCJ=SCCJ;
			model.DJGL=DJGL;
			model.DJTDFS=DJTDFS;
			model.DJZS=DJZS;
			model.ISVALID=ISVALID;
			model.ISUSED=ISUSED;
			model.BZ=BZ;

			BDPOVERMACHINEBLL bll=new BDPOVERMACHINEBLL();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
